package com.jiuyou.websocket.enums;

public enum RequestType {

    CHECK_HEARTBEAT("CHECK_HEARTBEAT", "传什么返回什么"),
    MY_MSG_UNREAD_COUNT("MY_MSG_UNREAD_COUNT", "获取我的未读消息数量"),
    MY_MSG_LIST("MY_MSG_LIST", "获取我的消息列表"),
    DIALOG_BY_LIST("DIALOG_BY_LIST", "获取与某人的对话列表倒序分页"),
    UPDATE_READ_STATUS("UPDATE_READ_STATUS", "将某人发给我的信息变为已读"),

    SEND_MSG("SEND_MSG", "给某人发消息"),
    RECEIVE_MSG_INFORM("RECEIVE_MSG_INFORM", "收到新消息（服务端通知客户端）"),
    ENUM_OTHER("ENUM_OTHER",  "其他类型，不确定的类型"),
    APP_HIDE_FLAG("APP_HIDE_FLAG",  "应用隐藏状态"),

    ;

    private final String value;
    private final String info;

    RequestType(String value, String info) {
        this.value = value;
        this.info = info;
    }

    public String getValue() {
        return value;
    }

    public String getInfo() {
        return info;
    }

    public boolean equals(String value) {
        return this.value.equals(value);
    }

    public static String getInfoByValue(String value) {
        return RequestType.valueOf(value).getInfo();
    }

    public static RequestType getIfPresent(String value) {
        for (RequestType rt : RequestType.values()) {
            if (rt.equals(value)) {
                return rt;
            }
        }
        return ENUM_OTHER;
    }
}
